{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/root/miniconda3/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    }
   ],
   "source": [
    "from datasets import load_dataset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### download hg face k8s dataset \n",
    "- features: ['objective', 'command_name', 'command', 'description', 'syntax', 'flags', 'question'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DatasetDict({\n",
      "    train: Dataset({\n",
      "        features: ['objective', 'command_name', 'command', 'description', 'syntax', 'flags', 'question', 'chain_of_thought'],\n",
      "        num_rows: 34884\n",
      "    })\n",
      "})\n"
     ]
    }
   ],
   "source": [
    "name = \"ComponentSoft/k8s-kubectl-35k\"\n",
    "k8s_ds = load_dataset(name, cache_dir=\"/data/llms/dataset\")\n",
    "print(k8s_ds)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Map: 100%|██████████| 34884/34884 [00:00<00:00, 36467.25 examples/s]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Dataset({\n",
       "    features: ['objective', 'command_name', 'command', 'description', 'syntax', 'flags', 'question', 'chain_of_thought'],\n",
       "    num_rows: 34884\n",
       "})"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import json\n",
    "import datasets\n",
    "\n",
    "chatglm3_ds = []\n",
    "\n",
    "def show(example : datasets.formatting.formatting.LazyRow):\n",
    "    chatglm3_ds.append(\n",
    "        \n",
    "    )\n",
    "\n",
    "    if example['chain_of_thought'] != None:\n",
    "       print(example)\n",
    "    \n",
    "    #json.dumps(example)\n",
    "k8s_ds[\"train\"].map(show)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
